﻿define([
    'dojo/_base/declare',
    'geomap/plugins/layers/HeatMapLayer',
    'dojo/dom-construct',
], function (declare, BaseHeatMapLayer) {
    var HeatMapLayer = declare([BaseHeatMapLayer], {
        setData: function (mapView, layer) {
            var options = layer.layer || {};
            var data = $.extend(true, [], options.data);
            this.data = data;
            this.lngFieldName = options.lngFieldName || mapView.getLngFieldName();
            this.latFieldName = options.latFieldName || mapView.getLatFieldName();
            this.countFieldName = options.countFieldName || mapView.getCountFieldName();
            this.devicePixelRatio = 1;
            this.mapv = options.options.mapv;
            this.options = options.options || {};
            this.options.size = this.options.size || this.options.radius;
            this.options.minScale = options.minScale;
            this.options.maxScale = options.maxScale;
            this.options.maxOpacity = this.options.maxOpacity || this.options.opacity;
            this.maxOpacity = this.options.maxOpacity;
            this.gradient = options.gradient = this.options.gradient || {
                0.25: 'rgba(0, 0, 255, 1)',
                0.55: 'rgba(0, 255, 0, 1)',
                0.85: 'rgba(255, 255, 0, 1)',
                1.0: 'rgba(255, 0, 0, 1)',
            };
            this.init();

            if (options.options.isShowLegend) {
                this.getLegend(options.options.legendOptions);
            }
            if (typeof options.callback == 'function') {
                options.callback(layer);
            }
        },
    });
    return HeatMapLayer;
});
